package com.maxlen.coupon.controller.reception;

import com.maxlen.common.utils.R;
import com.maxlen.coupon.entity.dto.CouponReceptionEntityDTO;
import com.maxlen.coupon.service.CouponHistoryService;
import com.maxlen.coupon.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("coupon/reception")
public class ReceptionController {

    @Autowired
    private CouponHistoryService couponHistoryService;

    @Autowired
    private CouponService couponService;

    /**
     * 领取优惠券
     * @param couponId 优惠券 id
     * @return
     */
    @PostMapping("/receiveCoupon/{couponId}")
    public R receiveCoupon(@PathVariable String couponId){
        return couponHistoryService.receiveCoupon(couponId);
    }

    /**
     * 获取已经发布并且是自行领取的优惠券
     * @return
     */
    @GetMapping("/getReceiveCoupon")
    public R getReceiveCoupon(){
        return couponService.getReceiveCoupon();
    }

    /**
     * 根据会员 id 获取会员所拥有的优惠券，并判断是否可用
     * @param token
     * @return
     */
    @GetMapping("/getCouponByMemberId")
    public R getCouponByMemberId(@RequestParam String token){
        return couponHistoryService.getCouponByMemberId(token);
    }

    /**
     * 获取能使用的优惠券
     * @return
     */
    @GetMapping("/getCouponByCanUse")
    public R getCouponByCanUse(){
        return couponHistoryService.getCouponByCanUse();
    }

    /**
     * 获取已经使用的优惠券
     * @return
     */
    @GetMapping("/getCouponByAlreadyUse")
    public R getCouponByAlreadyUse(){
        return couponHistoryService.getCouponByAlreadyUse();
    }

    /**
     * 获取已经过期的优惠券
     * @return
     */
    @GetMapping("/getCouponByOutTime")
    public R getCouponByOutTime(){
        return couponHistoryService.getCouponByOutTime();
    }

}
